package org.fujene.memoryblock.structure;

public abstract class SerializableNumber<E> extends Number implements Cloneable{
	private static final long serialVersionUID = 1386640074433083732L;
	protected int length;

	// The child class must not rely on this constructor
	public SerializableNumber(int len){
		this.length = len;
	}

	public SerializableNumber(byte[] b, int len){
		this.length = len;
	}

	public abstract byte[] toByte();

	public abstract E fromByte(byte[] b);

	public abstract void setValue(E val);

	public abstract E getValue();

	public int length(){
		return length;
	}

	@SuppressWarnings("unchecked")
	@Override
	public SerializableNumber<E> clone(){
		// TODO Auto-generated method stub
		try{
			return (SerializableNumber<E>)super.clone();
		}catch(CloneNotSupportedException e){}
		return null;
	}
}
